//
//  CDetailViewController.m
//  BigTyre
//
//  Created by 田涛 on 2017/3/28.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import "CDetailViewController.h"
#import "CDetailIntroduce.h"
#import "CDetailParameter.h"
#import "CDetailSales.h"



@interface CDetailViewController ()<UIScrollViewDelegate>
//创建分段控制器的属性
@property(nonatomic, strong) UISegmentedControl*segmentedControl;
@property(nonatomic, strong) UIScrollView*scrollView;

@end

@implementation CDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor greenColor];
    [self getFengDuan];
}
-(void)getFengDuan{
    
    NSArray *array = [NSArray arrayWithObjects:@"商品介绍",@"具体参数",@"包装售后", nil];
    _segmentedControl=[[UISegmentedControl alloc]initWithItems:array];
    self.segmentedControl.tintColor = [UIColor clearColor];//透明状态
    //正常状态
    NSDictionary * normalTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:16.0f],NSForegroundColorAttributeName : [UIColor grayColor]};
    [self.segmentedControl setTitleTextAttributes:normalTextAttributes forState:UIControlStateNormal];
    //选中状态
    NSDictionary * selctedTextAttributes = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:20.0f],NSForegroundColorAttributeName : [UIColor redColor]};
    [self.segmentedControl setTitleTextAttributes:selctedTextAttributes forState:UIControlStateSelected];
    //位置
    _segmentedControl.frame=CGRectMake(0, 0, self.view.frame.size.width, 30);
    //响应
    [_segmentedControl addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
    //_segmentedControl.titleFont = [UIFont fontWithName:@"STHeitiSC-Light" size:16];//按钮的常态样式
    
    //显示到View上面
    [self.view addSubview:self.segmentedControl];
   
    
}
-(void)change:(UISegmentedControl *)sender{
    
    if (sender.selectedSegmentIndex == 0) {
        CDetailIntroduce*view=[[CDetailIntroduce alloc]initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height)];
        [self.view addSubview:view];
        //view.backgroundColor=[UIColor redColor];
        
        
        
    }else if (sender.selectedSegmentIndex == 1){
        CDetailParameter*view1=[[CDetailParameter alloc]initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height)];
        [self.view addSubview:view1];
        view1.backgroundColor=[UIColor blueColor];
        
        
    }else if (sender.selectedSegmentIndex == 2){
        
        CDetailSales*view2=[[CDetailSales alloc]initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height)];
        [self.view addSubview:view2];
        view2.backgroundColor=[UIColor blackColor];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
